package fi.iki.juri.units.generator;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

public class ParsedUnit implements Serializable {
	private static final long serialVersionUID = 1L;
	private String id;
	private final Collection<String> aliases;
	private String derive;
	private String fromFormula;
	private String toFormula;

	public ParsedUnit(final String id) {
		this();
		this.id = id;
	}

	public ParsedUnit() {
		aliases = new ArrayList<String>();
	}

	public void setId(final String id) {
		this.id = id;
	}
	
	public void addAlias(final String alias) {
		this.aliases.add(alias);
	}

	public void addAliases(final Collection<String> aliases) {
		this.aliases.addAll(aliases);
	}
	
	public void setDerive(final String derive) {
		this.derive = derive;
	}

	public void setFromFormula(final String fromFormula) {
		this.fromFormula = fromFormula;
	}

	public void setToFormula(final String toFormula) {
		this.toFormula = toFormula;
	}

	public String getDerive() {
		return derive;
	}

	public String getFromFormula() {
		return fromFormula;
	}

	public String getId() {
		return id;
	}

	public Iterable<String> getAliases() {
		return aliases;
	}

	public String getToFormula() {
		return toFormula;
	}
	
	public String toString() {
		return String.format("<ParsedUnit id:%s alias:%s derive:%s from:%s to:%s>",
				id, aliases, derive, fromFormula, toFormula);
	}
}
